package com.zoffy.catdiarybackend.common;

public class ResultUtils {
    public  static <T>  BaseResponse<T> success(T data){
        BaseResponse<T> baseResponse=new BaseResponse<>();
        baseResponse.setCode(StateCode.SUCCESS.getCode());
        baseResponse.setMessage(StateCode.SUCCESS.getMessage());
        baseResponse.setData(data);
        return baseResponse;
    }
    public  static <T>  BaseResponse<T> success(){
        BaseResponse<T> baseResponse=new BaseResponse<>();
        baseResponse.setCode(StateCode.SUCCESS.getCode());
        baseResponse.setMessage(StateCode.SUCCESS.getMessage());
        baseResponse.setData(null);
        return baseResponse;
    }
    public  static <T>  BaseResponse<T> error(StateCode stateCode){
        BaseResponse<T> baseResponse=new BaseResponse<>();
        baseResponse.setCode(stateCode.getCode());
        baseResponse.setMessage(stateCode.getMessage());
        baseResponse.setData(null);
        return baseResponse;
    }
    public  static <T>  BaseResponse<T> error(StateCode stateCode,String message){
        BaseResponse<T> baseResponse=new BaseResponse<>();
        baseResponse.setCode(stateCode.getCode());
        baseResponse.setMessage(message);
        baseResponse.setData(null);
        return baseResponse;
    }
    public  static <T>  BaseResponse<T> error(int code,String message){
        BaseResponse<T> baseResponse=new BaseResponse<>();
        baseResponse.setCode(code);
        baseResponse.setMessage(message);
        baseResponse.setData(null);
        return baseResponse;
    }
}
